#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int minCost(vector<vector<int>>& costs) {
        int n = costs.size();
        vector<vector<int>> as(n + 1, vector<int>(3));
        for (int i = 1; i <= n; i++)
        {
            as[i][0] = min(as[i - 1][1], as[i - 1][2]) + costs[i - 1][0];
            as[i][1] = min(as[i - 1][0], as[i - 1][2]) + costs[i - 1][1];
            as[i][2] = min(as[i - 1][0], as[i - 1][1]) + costs[i - 1][2];
        }
        return min(min(as[n][0], as[n][1]), as[n][2]);

    }
};